package com.atomscat.lottery.service;


import com.atomscat.lottery.entity.constant.ResponseEnum;
import com.atomscat.lottery.entity.vo.response.BaseResponse;
import org.springframework.stereotype.Service;

@Service
public class VoBaseRespTransformService {

    public <Resp> BaseResponse<Resp> transformSuccessful(Resp resp) {
        BaseResponse<Resp> baseResponse = new BaseResponse<>();
        baseResponse.setCode(ResponseEnum.SUCCESSFUL.getCode());
        baseResponse.setMsg(ResponseEnum.SUCCESSFUL.getMessage());
        baseResponse.setData(resp);
        return baseResponse;
    }

    public <Resp> BaseResponse<Resp> transformExpiration(Resp resp) {
        BaseResponse<Resp> baseResponse = new BaseResponse<>();
        baseResponse.setCode(ResponseEnum.EXPIRATION.getCode());
        baseResponse.setMsg(ResponseEnum.EXPIRATION.getMessage());
        baseResponse.setData(resp);
        return baseResponse;
    }

    public <Resp> BaseResponse<Resp> transformBadRequest(Resp resp) {
        BaseResponse<Resp> baseResponse = new BaseResponse<>();
        baseResponse.setCode(ResponseEnum.BAD_REQUEST.getCode());
        baseResponse.setMsg(ResponseEnum.BAD_REQUEST.getMessage());
        baseResponse.setData(resp);
        return baseResponse;
    }

    public <Resp> BaseResponse<Resp> transformInvalid(Resp resp) {
        BaseResponse<Resp> baseResponse = new BaseResponse<>();
        baseResponse.setCode(ResponseEnum.INVALID.getCode());
        baseResponse.setMsg(ResponseEnum.INVALID.getMessage());
        baseResponse.setData(resp);
        return baseResponse;
    }

    public <Resp> BaseResponse<Resp> transformUnavailable(Resp resp) {
        BaseResponse<Resp> baseResponse = new BaseResponse<>();
        baseResponse.setCode(ResponseEnum.UNAVAILABLE.getCode());
        baseResponse.setMsg(ResponseEnum.UNAVAILABLE.getMessage());
        baseResponse.setData(resp);
        return baseResponse;
    }

}
